<template>
<el-dialog title="详情"
           :close-on-click-modal="false" append-to-body
           :visible.sync="visible" class="JNPF-dialog JNPF-dialog_center" lock-scroll
           width="600px">
<el-row :gutter="15" class="">
<el-form ref="elForm" :model="dataForm" size="small" label-width="100px" label-position="right" >
    <template v-if="!loading">
            <el-col :span="24"  >
                <jnpf-form-tip-item  label="商品名称"  
 prop="productname"  >
                        <p>{{dataForm.productname}}</p>
                </jnpf-form-tip-item>
            </el-col>
            <el-col :span="24"  >
                <jnpf-form-tip-item  label="商品编码"  
 prop="productcode"  >
                        <p>{{dataForm.productcode}}</p>
                </jnpf-form-tip-item>
            </el-col>
            <el-col :span="24"  >
                <jnpf-form-tip-item  label="分类名称"  
 prop="categoryname"  >
                        <p>{{dataForm.categoryname}}</p>
                </jnpf-form-tip-item>
            </el-col>
            <el-col :span="24"  >
                <jnpf-form-tip-item  label="分类路径"  
 prop="categoryurl"  >
                        <p>{{dataForm.categoryurl}}</p>
                </jnpf-form-tip-item>
            </el-col>
            <el-col :span="24"  >
                <jnpf-form-tip-item  label="价格"  
 prop="price"  >
                    <JnpfNumber    v-model="dataForm.price_name"
 placeholder="数字文本"  disabled
 :step="1"  :precision="2"  >
                </JnpfNumber>
                </jnpf-form-tip-item>
            </el-col>
            <el-col :span="24"  >
                <jnpf-form-tip-item  label="平台类型"  
 prop="platformtype"  >
                        <p>{{dataForm.platformtype}}</p>
                </jnpf-form-tip-item>
            </el-col>
            <el-col :span="24"  >
                <jnpf-form-tip-item  label="上架"  
 prop="putaway"  >
                        <p>{{dataForm.putaway}}</p>
                </jnpf-form-tip-item>
            </el-col>
            <el-col :span="24"  >
                <jnpf-form-tip-item  label="缩略图"  
 prop="thumbnail"  >
                    <JNPF-UploadImg    v-model="dataForm.thumbnail"
 disabled
 detailed  :fileSize="50"  sizeUnit="MB"  :limit="1"  pathType="defaultPath"  :isAccount="0"  >
                </JNPF-UploadImg>
                </jnpf-form-tip-item>
            </el-col>
            <el-col :span="24"  >
                <jnpf-form-tip-item  label="详情图"  
 prop="detailchart"  >
                    <JNPF-UploadImg    v-model="dataForm.detailchart"
 disabled
 detailed  :fileSize="20"  sizeUnit="MB"  :limit="9"  pathType="defaultPath"  :isAccount="0"  >
                </JNPF-UploadImg>
                </jnpf-form-tip-item>
            </el-col>
    </template>
</el-form>
    </el-row>
    <span slot="footer" class="dialog-footer">
        <el-button @click="visible = false"> 取 消</el-button>
    </span>
    <Detail v-if="detailVisible" ref="Detail" @close="detailVisible = false" />
    </el-dialog>
</template>
<script>
    import request from '@/utils/request'

    import { getConfigData } from '@/api/onlineDev/visualDev'
    import jnpf from '@/utils/jnpf'
    import Detail from '@/views/basic/dynamicModel/list/detail'
    import { thousandsFormat } from "@/components/Generator/utils/index"
    export default {
        components: { Detail},
        props: [],
        data() {
            return {
                visible: false,
                detailVisible: false,
                loading: false,

            dataForm: {
                id :'',
                            productname : '',
                            productcode : '',
                            categoryname : '',
                            categoryurl : '',
                            price : 0,
                            platformtype : "",
                            putaway : "false",
                            thumbnail : [],
                            detailchart : [],
            },
                        platformtypeProps:{"label":"fullName","value":"id"  },
                        putawayProps:{"label":"fullName","value":"enCode"  },

        }
        },
        computed: {},
        watch: {},
        created() {

        },
        mounted() {},
        methods: {
            toDetail(defaultValue, modelId) {
                if (!defaultValue) return
                getConfigData(modelId).then(res => {
                    if (!res.data || !res.data.formData) return
                    let formData = JSON.parse(res.data.formData)
                    formData.popupType = 'general'
                    this.detailVisible = true
                    this.$nextTick(() => {
                        this.$refs.Detail.init(formData, modelId, defaultValue)
                    })
                })
            },
            dataInfo(dataAll){
                let _dataAll =dataAll
                        _dataAll.thumbnail = _dataAll.thumbnail ? JSON.parse( _dataAll.thumbnail):[]
                        _dataAll.detailchart = _dataAll.detailchart ? JSON.parse( _dataAll.detailchart):[]
                this.dataForm = _dataAll
            },

            init(id) {
                this.dataForm.id = id || 0;
                this.visible = true;
                this.$nextTick(() => {
                    if(this.dataForm.id){
                        this.loading = true
                        request({
                            url: '/api/example/BankGood/detail/'+this.dataForm.id,
                            method: 'get'
                        }).then(res => {
                            this.dataInfo(res.data)
                            this.loading = false
                        })
                    }

                })
            },
        },
    }

</script>
